from bcat.rpc.client.server_proxy import IServerProxyImpl
from bcat.rpc.client.server_proxies.common_server_proxy import CommonServerProxy

class TwoFactorServerProxy(CommonServerProxy):
    def __init__(self, url: str, impl: IServerProxyImpl):
        super().__init__(url, impl)

    def sign(self) -> str:
        return self.impl().stub().sign()

    def device_on_line(self) -> bool:
        return self.impl().stub().device_on_line()

    def add(self, x, y) -> int:
        return self.impl().stub().add(x, y) 


import unittest 
from bcat.rpc.client.server_proxy_impls.jsonrpclib_server_proxyimpl import JsonRpcLibServerProxyImpl
class TestClient(unittest.TestCase):
    def test_jsonrpclib(self):
        url = "http://127.0.0.1:5000/api"
        sp = TwoFactorServerProxy(url, JsonRpcLibServerProxyImpl(url))
        #print(sp.add(1, 1))
        print(sp.tick())
        print(sp.exit())

